package Simulation;


public class BatchArrival extends SimEvent {

	public int amount = 0;

	public static long counter = 0;
			
	public BatchArrival(long time) {
		this(time, 1);
	}

	public BatchArrival(long time, int amount) {
		super(time);
		this.amount = amount;
	}

	@Override
	public void process() {
		counter++;
		SimState state = SimState.instance;
		// remember how long the queue was on arrival for the statistics
		state.waiting_queue_length.count(state.waiting_queue.size());
		long time = state.now;

		// one iteration for each customer in the batch arrival
		for (int i = 0; i < amount; i++) {
			// for all iterations but the very first we sum up the
			// inter-customer time within a batch
			time = (i == 0) ? time : time + state.getNextBatchInterCustomerArrivalTime();
			state.ec.add(new CustomerArrival(time, false));
		}
		state.ec.add(new BatchArrival(state.now
				+ state.getNextInterArrivalTime(), 5));
	}


}
